package com.msb.dongbao.portal.web.controller.studyCaptcha;

import com.msb.dongbao.portal.web.util.SliderUtil;
import com.ramostear.captcha.HappyCaptcha;
import com.wf.captcha.utils.CaptchaUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/my-slider")
public class MySliderController {

    @GetMapping("/generator")
    public void generatorCode(HttpServletRequest request, HttpServletResponse response) {
        SliderUtil.cut();
    }


    @GetMapping("/verify")
    public String verify(String verifyCode, HttpServletRequest request) {
        Boolean aBoolean = CaptchaUtil.ver(verifyCode, request);
        if (aBoolean) {
            HappyCaptcha.remove(request);
            return "通过";
        }
        return "不通过";
    }

}
